package labox.innovation.gameserver.network.clientpackets;

import labox.innovation.config.Config;
import labox.innovation.gameserver.network.L2GameClient;

/**
 * 客户端回应心跳校验
 * 
 * @author squll
 */
public final class GameGuardReply extends L2GameClientPacket {

	private static final String _C__CA_GAMEGUARDREPLY = "[C] CA GameGuardReply";

	private int _frameCount;

	@Override
	protected void readImpl() {
		_frameCount = readInt();
	}

	@Override
	protected void runImpl() {
		L2GameClient client = getClient();
		if (client == null)
			return;
		int _oldCOunt = client.getGuardCount();
		if (_oldCOunt == 0) {
			client.setGameGuardOk(true);
		} else {
			int interval = _frameCount - _oldCOunt;
			if (interval > 0) {
				client.setGameGuardOk(true);
			}
		}
		client.setGuardCount(_frameCount);
	}

	@Override
	public String getType() {
		return _C__CA_GAMEGUARDREPLY;
	}

}
